package com.example.librarymanagement.vo;

import com.example.librarymanagement.util.DateFormatUtil;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.experimental.Accessors;

import java.sql.Date;
import java.sql.Timestamp;

/**
 * @author ZHB
 */
@Data
@Accessors(chain = true)
public class ReaderVo {

    @ApiParam(value = "id")
    private Integer id;

    @ApiParam(value = "用户id")
    private Integer userId;

    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "读者姓名")
    private String name;

    @ApiModelProperty(value = "读者性别")
    private Integer sex;

    @ApiModelProperty(value = "所属单位")
    private String affiliatedUnit;

    @ApiModelProperty(value = "创建日期")
    private String createTime;

    @ApiModelProperty(value = "身份证号")
    private String idCard;

    @ApiModelProperty(value = "出生日期")
    private String birthday;

    @ApiModelProperty(value = "借阅数量")
    private Integer borrowCount;

    @ApiModelProperty(value = "已归还数量")
    private Integer returnCount;

    public void setCreateTime(Timestamp createTime) {
        if (createTime != null) {
            this.createTime = DateFormatUtil.formatDate("yyyy-MM-dd HH:mm:ss", createTime);
        }
    }

    public void setBirthday(Timestamp birthday) {
        if (birthday != null) {
            this.birthday = DateFormatUtil.convertDateToString(birthday);
        }
    }
}
